﻿using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework;
using ZeldoEngine;
using ZeldoEngineObjects;

namespace MapEditorXna.Ui
{
    public class Selection
    {
        public int StartTile { get; set; }
        public int EndTile { get; set; }

        private Texture2D _tileTexture;

        public int X { get; set; }
        public int Y { get; set; }
        public int Width { get; set; }
        public int Height { get; set; }

        public bool Show { get; set; }

        public Selection()
        {
            this.Show = false;
        }

        public void Load(ContentManager content,GraphicsDevice graphDevice)
        {
            this._tileTexture = content.Load<Texture2D>("white");
        }

        public void Draw(SpriteBatch spriteBach)
        {
            if (this.Show)
            {
                var positionX = this.X - (this.X % EngineConsts.TILE_SIZE);
                var positionY = this.Y - (this.Y % EngineConsts.TILE_SIZE);

                spriteBach.Draw(this._tileTexture, new Microsoft.Xna.Framework.Rectangle(positionX, positionY, this.Width, 2), Color.Azure);
                spriteBach.Draw(this._tileTexture, new Microsoft.Xna.Framework.Rectangle(positionX, positionY + this.Height - 2, this.Width, 2), Color.Azure);
                spriteBach.Draw(this._tileTexture, new Microsoft.Xna.Framework.Rectangle(positionX, positionY, 2, this.Height), Color.Azure);
                spriteBach.Draw(this._tileTexture, new Microsoft.Xna.Framework.Rectangle(positionX + this.Width - 2, positionY, 2, this.Height), Color.Azure);
            }
        }
    }
}
